package com.caigou.component;

import com.caigou.bean.cms.entity.AdConfig;
import com.caigou.bean.cms.entity.AdList;
import com.caigou.service.AdConfigService;
import com.caigou.service.AdListService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
@Component
public class HtmlBuildAdComponent {

    @Resource
    private TemplateComponent templateComponent;

    @Resource
    private AdConfigService adConfigService;
    @Resource
    private AdListService adListService;

    public void buildAdHtml(String adConfigCode){
        if (null == adConfigCode || adConfigCode.equals("")){ log.error("参数传递异常");return; }
        AdConfig adConfig = adConfigService.loadAdConfigByAdCode(adConfigCode);
        if (null == adConfig){ log.error("获取到的广告位配置信息adConfig为空");return; }
        Map<String, Object> map = new HashMap<>();

        String templateCode = "";
        switch (adConfigCode){
            case "A01":// 首页首页遮浮广告
                templateCode = "HOMEFRAGMENTADSHADE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "A02":// 首页首页顶部通栏广告
                templateCode = "HOMEFRAGMENTADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "A03"://首页首页专业频道资讯下方广告
                templateCode = "HOMEFRAGMENTADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "A04":// 首页首页易找标产品宣传下方广告
                templateCode = "HOMEFRAGMENTADFULLCOLUMNTHREE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "A05":// 首页首页“亚利聊政采”下方广告
                templateCode = "HOMEFRAGMENTADRIGHTONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "A06":// 首页首页“热点专题”下方广告
                templateCode = "HOMEFRAGMENTADRIGHTTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "A07":// 首页首页“人物观点”下方广告
                templateCode = "HOMEFRAGMENTADRIGHTTHREE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "A08":// 首页频道列表页广告1
                templateCode = "HOMEFRAGMENTADLISTONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "A09":// 首页频道列表页广告2
                templateCode = "HOMEFRAGMENTADLISTTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "A10":// 首页频道底层页广告1(不含图集)
            case "A11":// 首页频道底层页广告2(不含图集)
            case "A12":// 首页频道底层页广告3(不含图集)
                templateCode = "HOMEFRAGMENTARTICLEAD";
                List<String> homeCodeList = new ArrayList<>();
                homeCodeList.add("A10");
                homeCodeList.add("A11");
                homeCodeList.add("A12");
                map = disposeTemplateMap(2,null,homeCodeList);
                break;
            case "A13":// 首页频道图集类广告
                templateCode = "HOMEFRAGMENTARTICLEALBUMAD";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "Q01":// 汽车首页行业资讯下方广告
                templateCode = "AUTOFRAGMENTADLEFTONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "Q02":// 汽车首页“大标推荐”下方广告
                templateCode = "AUTOFRAGMENTADRIGHTONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "Q03":// 汽车首页“好车汇”下方广告
                templateCode = "AUTOFRAGMENTADRIGHTTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "Q04":// 汽车频道列表页广告1
                templateCode = "AUTOFRAGMENTADLISTONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "Q05":// 汽车频道列表页广告2
                templateCode = "AUTOFRAGMENTADLISTTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "Q06":// 汽车频道底层页广告1(不含图集)
            case "Q07":// 汽车频道底层页广告2(不含图集)
            case "Q08":// 汽车频道底层页广告3(不含图集)
                templateCode = "AUTOFRAGMENTARTICLEAD";
                List<String> autoCodeList = new ArrayList<>();
                autoCodeList.add("Q06");
                autoCodeList.add("Q07");
                autoCodeList.add("Q08");
                map = disposeTemplateMap(2,null,autoCodeList);
                break;
            case "Q09":// 汽车频道图集类广告
                templateCode = "AUTOFRAGMENTARTICLEALBUMAD";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "X01":// IT首页行业资讯下方广告
                templateCode = "ITFRAGMENTADLEFTONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "X02":// IT首页“大标推荐”下方广告
                templateCode = "ITFRAGMENTADRIGHTONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "X03":// IT首页“评优评测”下方广告
                templateCode = "ITFRAGMENTADRIGHTTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "X04":// IT频道列表页广告1
                templateCode = "ITFRAGMENTADLISTONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "X05":// IT频道列表页广告2
                templateCode = "ITFRAGMENTADLISTTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "X06":// IT频道底层页广告1(不含图集)
            case "X07":// IT频道底层页广告2(不含图集)
            case "X08":// IT频道底层页广告3(不含图集)
                templateCode = "ITFRAGMENTARTICLEAD";
                List<String> itCodeList = new ArrayList<>();
                itCodeList.add("X06");
                itCodeList.add("X07");
                itCodeList.add("X08");
                map = disposeTemplateMap(2,null,itCodeList);
                break;
            case "X09":// IT频道图集类广告
                templateCode = "ITFRAGMENTARTICLEALBUMAD";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "D01":// 电梯首页行业资讯下方广告
                templateCode = "ELEVATORFRAGMENTADLEFTONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "D02":// 电梯首页“大标推荐”下方广告
                templateCode = "ELEVATORFRAGMENTADRIGHTONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "D03":// 电梯首页“评优评测”下方广告
                templateCode = "ELEVATORFRAGMENTADRIGHTTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "D04":// 电梯频道列表页广告1
                templateCode = "ELEVATORFRAGMENTADLISTONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "D05":// 电梯频道列表页广告2
                templateCode = "ELEVATORFRAGMENTADLISTTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "D06":// 电梯频道底层页广告1(不含图集)
            case "D07":// 电梯频道底层页广告2(不含图集)
            case "D08":// 电梯频道底层页广告3(不含图集)
                templateCode = "ELEVATORFRAGMENTARTICLEAD";
                List<String> elevatorCodeList = new ArrayList<>();
                elevatorCodeList.add("D06");
                elevatorCodeList.add("D07");
                elevatorCodeList.add("D08");
                map = disposeTemplateMap(2,null,elevatorCodeList);
                break;
            case "D09":// 电梯频道图集类广告
                templateCode = "ELEVATORFRAGMENTARTICLEALBUMAD";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "K01":// 空调电器首页行业资讯下方广告
                templateCode = "CONDITIONERFRAGMENTADLEFTONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "K02":// 空调电器首页“大标推荐”下方广告
                templateCode = "CONDITIONERFRAGMENTADRIGHTONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "K03":// 空调电器首页“评优评测”下方广告
                templateCode = "CONDITIONERFRAGMENTADRIGHTTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "K04":// 空调电器频道列表页广告1
                templateCode = "CONDITIONERFRAGMENTADLISTONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "K05":// 空调电器频道列表页广告2
                templateCode = "CONDITIONERFRAGMENTADLISTTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "K06":// 空调电器频道底层页广告1(不含图集)
            case "K07":// 空调电器频道底层页广告2(不含图集)
            case "K08":// 空调电器频道底层页广告3(不含图集)
                templateCode = "CONDITIONERFRAGMENTARTICLEAD";
                List<String> conditionerCodeList = new ArrayList<>();
                conditionerCodeList.add("D06");
                conditionerCodeList.add("D07");
                conditionerCodeList.add("D08");
                map = disposeTemplateMap(2,null,conditionerCodeList);
                break;
            case "K09":// 空调电器频道图集类广告
                templateCode = "CONDITIONERFRAGMENTARTICLEALBUMAD";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "J01":// 家具首页行业资讯下方广告
                templateCode = "FURNITUREFRAGMENTADLEFTONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "J02":// 家具首页“大标推荐”下方广告
                templateCode = "FURNITUREFRAGMENTADRIGHTONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "J03":// 家具首页“评优评测”下方广告
                templateCode = "FURNITUREFRAGMENTADRIGHTTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "J04":// 家具频道列表页广告1
                templateCode = "FURNITUREFRAGMENTADLISTONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "J05":// 家具频道列表页广告2
                templateCode = "FURNITUREFRAGMENTADLISTTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "J06":// 家具频道底层页广告1(不含图集)
            case "J07":// 家具频道底层页广告2(不含图集)
            case "J08":// 家具频道底层页广告3(不含图集)
                templateCode = "FURNITUREFRAGMENTARTICLEAD";
                List<String> furnitureCodeList = new ArrayList<>();
                furnitureCodeList.add("J06");
                furnitureCodeList.add("J07");
                furnitureCodeList.add("J08");
                map = disposeTemplateMap(2,null,furnitureCodeList);
                break;
            case "J09":// 家具频道图集类广告
                templateCode = "FURNITUREFRAGMENTARTICLEALBUMAD";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "C01":// 采购人页面顶部通栏广告
                templateCode = "PURCHASERFRAGMENTADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "C02":// 采购人页面中部通栏广告
                templateCode = "PURCHASERFRAGMENTADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "C03":// 采购人全频道列表页广告1
                templateCode = "PURCHASERFRAGMENTADLISTONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "C04":// 采购人全频道列表页广告2
                templateCode = "PURCHASERFRAGMENTADLISTTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "C05":// 采购人全频道底层页广告1
            case "C06":// 采购人全频道底层页广告2
            case "C07":// 采购人全频道底层页广告3
                templateCode = "PURCHASERFRAGMENTARTICLEAD";
                List<String> purchaserCodeList = new ArrayList<>();
                purchaserCodeList.add("J06");
                purchaserCodeList.add("J07");
                purchaserCodeList.add("J08");
                map = disposeTemplateMap(2,null,purchaserCodeList);
                break;
            case "C08":// 采购人全频道图集类广告
                templateCode = "PURCHASERFRAGMENTARTICLEALBUMAD";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "S01":// 实务页面顶部通栏广告
                templateCode = "PRACTICEFRAGMENTADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "S02":// 实务页面中部通栏广告
                templateCode = "PRACTICEFRAGMENTADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "S03":// 实务全频道列表页广告1
                templateCode = "PRACTICEFRAGMENTADLISTONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "S04":// 实务全频道列表页广告2
                templateCode = "PRACTICEFRAGMENTADLISTTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "S05":// 实务全频道底层页广告1
            case "S06":// 实务全频道底层页广告2
            case "S07":// 实务全频道底层页广告3
                templateCode = "PRACTICEFRAGMENTARTICLEAD";
                List<String> practiceCodeList = new ArrayList<>();
                practiceCodeList.add("S05");
                practiceCodeList.add("S06");
                practiceCodeList.add("S07");
                map = disposeTemplateMap(2,null,practiceCodeList);
                break;
            case "S08":// 实务全频道图集类广告
                templateCode = "PRACTICEFRAGMENTARTICLEALBUMAD";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "G01":// 监管页面顶部通栏广告
                templateCode = "SUPERVISEFRAGMENTADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "G02":// 监管页面中部通栏广告
                templateCode = "SUPERVISEFRAGMENTADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "G03":// 监管全频道列表页广告1
                templateCode = "SUPERVISEFRAGMENTADLISTONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "G04":// 监管全频道列表页广告2
                templateCode = "SUPERVISEFRAGMENTADLISTTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "G05":// 监管全频道底层页广告1
            case "G06":// 监管全频道底层页广告2
            case "G07":// 监管权频道底层页广告3
                templateCode = "SUPERVISEFRAGMENTARTICLEAD";
                List<String> superviseCodeList = new ArrayList<>();
                superviseCodeList.add("G05");
                superviseCodeList.add("G06");
                superviseCodeList.add("G07");
                map = disposeTemplateMap(2,null,superviseCodeList);
                break;
            case "G08":// 监管全频道图集类广告
                templateCode = "SUPERVISEFRAGMENTARTICLEALBUMAD";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "Y01":// 研究院页面顶部通栏广告
                templateCode = "INSTITUTEFRAGMENTADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "Y02":// 研究院页面中部通栏广告
                templateCode = "INSTITUTEFRAGMENTADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "Y03":// 研究院页面侧边栏广告1
                templateCode = "INSTITUTEFRAGMENTADRIGHTONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "Y04":// 研究院全频道列表页广告1
                templateCode = "INSTITUTEFRAGMENTADLISTONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "Y05":// 研究院全频道列表页广告2
                templateCode = "INSTITUTEFRAGMENTADLISTTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "Y06":// 研究院全频道底层页广告1
            case "Y07":// 研究院全频道底层页广告2
            case "Y08":// 研究院全频道底层页广告3
                templateCode = "INSTITUTEFRAGMENTARTICLEAD";
                List<String> instituteCodeList = new ArrayList<>();
                instituteCodeList.add("Y06");
                instituteCodeList.add("Y07");
                instituteCodeList.add("Y08");
                map = disposeTemplateMap(2,null,instituteCodeList);
                break;
            case "Y09":// 研究院全频道图集类广告
                templateCode = "INSTITUTEFRAGMENTARTICLEALBUMAD";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "V01":// 军队页面顶部通栏广告
                templateCode = "ARMYFRAGMENTADFULLCOLUMBONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "V02":// 军队页面中部通栏广告
                templateCode = "ARMYFRAGMENTADFULLCOLUMBTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "V03":// 军队全频道列表页广告1
                templateCode = "ARMYFRAGMENTADLISTONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "V04":// 军队全频道列表页广告2
                templateCode = "ARMYFRAGMENTADLISTTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "V05":// 军队全频道底层页广告1
            case "V06":// 军队全频道底层页广告2
            case "V07":// 军队全频道底层页广告3
                templateCode = "ARMYFRAGMENTARTICLEAD";
                List<String> armyCodeList = new ArrayList<>();
                armyCodeList.add("V05");
                armyCodeList.add("V06");
                armyCodeList.add("V07");
                map = disposeTemplateMap(2,null,armyCodeList);
                break;
            case "V08":// 军队全频道图集类广告
                templateCode = "ARMYFRAGMENTARTICLEALBUMAD";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "Z01":// 专题列表通栏广告
                templateCode = "SPECIALTOPAD";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;

            case "F_HEB01":// 河北
                templateCode = "HEBEIADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_HEB02":// 河北
                templateCode = "HEBEIADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_HEN01":// 河南分站首页顶部通栏广告
                templateCode = "HENANADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_HEN02":// 河南分站首页半通栏广告
                templateCode = "HENANADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_SD01":// 山东
                templateCode = "SHANDONGADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_SD02":// 山东
                templateCode = "SHANDONGADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_LN01":// 辽宁分站首页顶部通栏广告
                templateCode = "LIAONINGADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_LN02":// 辽宁分站首页半通栏广告
                templateCode = "LIAONINGADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_JS01":// 辽宁分站首页顶部通栏广告
                templateCode = "JIANGSUADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_JS02":// 辽宁分站首页半通栏广告
                templateCode = "JIANGSUADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_FJ01":// 福建分站首页顶部通栏广告
                templateCode = "FUJIANADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_FJ02":// 福建分站首页半通栏广告
                templateCode = "FUJIANADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_HB01":// 湖北分站首页顶部通栏广告
                templateCode = "HUBEIADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_HB02":// 湖北分站首页半通栏广告
                templateCode = "HUBEIADFULLCOLUMNtWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_HAIN01":// 海南分站首页顶部通栏广告
                templateCode = "HAINANADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_HAIN02":// 海南分站首页半通栏广告
                templateCode = "HAINANADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_SHX01":// 陕西分站首页顶部通栏广告
                templateCode = "SHAANXIADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_SHX02":// 陕西分站首页半通栏广告
                templateCode = "SHAANXIADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_BJ01":// 北京分站首页顶部通栏广告
                templateCode = "BEIJINGADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_BJ02":// 北京分站首页半通栏广告
                templateCode = "BEIJINGADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_ZJ01":// 浙江分站首页顶部通栏广告
                templateCode = "ZHEJIANGADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_ZJ02":// 浙江分站首页半通栏广告
                templateCode = "ZHEJIANGADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_YN01":// 云南分站首页顶部通栏广告
                templateCode = "YUNNANADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_YN02":// 云南分站首页半通栏广告
                templateCode = "YUNNANADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_GZ01":// 贵州分站首页顶部通栏广告
                templateCode = "GUIZHOUADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_GZ02":// 贵州分站首页半通栏广告
                templateCode = "GUIZHOUADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_CQ01":// 重庆分站首页顶部通栏广告
                templateCode = "CHONGQINGADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_CQ02":// 重庆分站首页半通栏广告
                templateCode = "CHONGQINGADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_TJ01":// 天津分站首页顶部通栏广告
                templateCode = "TIANJINADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_TJ02":// 天津分站首页半通栏广告
                templateCode = "TIANJINADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_SZ01":// 深圳分站首页顶部通栏广告
                templateCode = "SHENZHENADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_SZ02":// 深圳分站首页半通栏广告
                templateCode = "SHENZHENADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_QD01":// 青岛分站首页顶部通栏广告
                templateCode = "QINGDAOADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_QD02":// 青岛分站首页半通栏广告
                templateCode = "QINGDAOADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_DL01":// 大连分站首页顶部通栏广告
                templateCode = "DALIANADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_DL02":// 大连分站首页半通栏广告
                templateCode = "DALIANADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_XZ01":// 西藏分站首页顶部通栏广告
                templateCode = "XIZANGADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_XZ02":// 西藏分站首页半通栏广告
                templateCode = "XIZANGADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_XJ01":// 新疆分站首页顶部通栏广告
                templateCode = "XINJIANGADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_XJ02":// 新疆分站首页半通栏广告
                templateCode = "XINJIANGADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_NX01":// 宁夏分站首页顶部通栏广告
                templateCode = "NINGXIAADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_NX02":// 宁夏分站首页半通栏广告
                templateCode = "NINGXIAADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_GX01":// 广西分站首页顶部通栏广告
                templateCode = "GUANGXIADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_GX02":// 广西分站首页半通栏广告
                templateCode = "GUANGXIADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_NMG01":// 内蒙古分站首页顶部通栏广告
                templateCode = "NEIMENGGUADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_NMG02":// 内蒙古分站首页半通栏广告
                templateCode = "NEIMENGGUADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_GS01":// 甘肃分站首页顶部通栏广告
                templateCode = "GANSUADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_GS02":// 甘肃分站首页半通栏广告
                templateCode = "GANSUADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_BT01":// 新疆生产建设兵团分站首页顶部通栏广告
                templateCode = "BINGTUANADFULLCOLUMNONE";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;
            case "F_BT02":// 新疆生产建设兵团分站首页半通栏广告
                templateCode = "BINGTUANADFULLCOLUMNTWO";
                map = disposeTemplateMap(1,adConfigCode,null);
                break;

        }
        // 如果没有捕获到模板编号--则代表当前广告位不需要更新静态页，因此return出去
        if (templateCode.equals("")) {
            log.info("当前广告位不需要更新静态页");
            return;
        }
        // 进行静态页生成方法调用
        try {
            templateComponent.createHtml(templateCode, map);
        } catch (IOException e){
            log.error("静态文件生成失败，失败原因是={}", e.getMessage());
        }
    }

    private Map<String, Object> disposeTemplateMap(Integer templateType, String code, List<String> codeList) {
        log.info("传入的code是---》"+code);
        Map<String, Object> map = new HashMap<>();
        switch (templateType) {
            case 1:// 同步更新一条
                AdList ad = adListService.loadAdListByAdConfigCode(code);
                if (null != ad){
                    AdConfig adConfig = adConfigService.loadAdConfigByAdCode(code);
                    ad.setAdShowStatus(adConfig.getAdShowStatus());
                    ad.setAdLogoStatus(adConfig.getAdLogoStatus());
                    map.put("adList", ad);
                } else {
                    log.error("广告位更新失败--获取到的广告信息adList为空");
                }
                break;
            case 2:// 同步更新多条
                List<AdList> adList = new ArrayList<>();
                // 页卡内容数据
                for (int i = 0; i < codeList.size(); i++) {
                    AdList adData = adListService.loadAdListByAdConfigCode(codeList.get(i));
                    AdConfig adConfig = adConfigService.loadAdConfigByAdCode(codeList.get(i));
                    adData.setAdShowStatus(adConfig.getAdShowStatus());
                    adData.setAdLogoStatus(adConfig.getAdLogoStatus());
                    adList.add(adData);
                }
                map.put("adList", adList);
                break;
        }
        return map;
    }
}
